#include <stdio.h>
#include <math.h>
#include "eno.h"

#define data_max_x 132

#define pi 3.14159265358

double z1[data_max_x+1][2*data_max_x+1],
       z2[data_max_x+1][2*data_max_x+1];
int num_side1,num_side2,i,xstep,ystep,boundary_size;
FILE *in_file1,*in_file2,*out_file;
char in_file_name1[20],in_file_name2[20];
double z_avg,l2_norm,temp_float,r_end,hh;

int slide_number1,slide_number2,num_side1_y,num_side2_y,use_distance_int,
    slide_count;
double file_var,file_var1,file_var2,density_above,
       density_below,current_delta_x;
logical use_distance;


void main()
{
int scan_status,p_status;

  printf("This program combines u,v into speed.tmp \n");
 
  printf("Enter file 1 (u) => \n");
  scan_status = scanf("%19s",in_file_name1);
  printf("Enter file 2 (v) => \n");
  scan_status = scanf("%19s",in_file_name2);
  in_file1 = fopen(in_file_name1,"r");
  in_file2 = fopen(in_file_name2,"r");
  out_file = fopen("speed.tmp","w");

  scan_status = fscanf(in_file1,"%d\n",&num_side1);
  scan_status = fscanf(in_file2,"%d\n",&num_side2);
  p_status=fprintf(out_file,"%5d\n",num_side1);

  printf("u grid : %5d\n",num_side1);
  printf("enter number of points in y direction for u grid=>\n");
  scan_status = scanf("%d",&num_side1_y);
  printf("enter total number of slides=>\n");
  scan_status = scanf("%d",&slide_number1);

  for (slide_count=0;slide_count<=slide_number1;slide_count++)
   {
    for (ystep = 1;ystep <= num_side1_y;ystep++)
     for (xstep = 1;xstep <= num_side1;xstep++)
      {
       scan_status = fscanf(in_file1,"%lf\n",&file_var1);
       scan_status = fscanf(in_file2,"%lf\n",&file_var2);
       file_var=sqrt(sqr(file_var1)+sqr(file_var2));
       p_status=fprintf(out_file,"%10.4f\n",file_var);
      }

    if (slide_count<slide_number1)
     {
      scan_status = fscanf(in_file1,"%d\n",&num_side1);
      scan_status = fscanf(in_file2,"%d\n",&num_side2);
      p_status=fprintf(out_file,"%5d\n",num_side1);
      printf("it side %5d\n",num_side1);
     }
   }
  scan_status = fclose(in_file1);
  scan_status = fclose(in_file2);
  scan_status = fclose(out_file);
  
  return;
}
